<template>
  <PageTemplate rowKey="affairId" :tableRequest="tableRequest"
                :metaDataRequestParams="metaDataRequestParams" :toolButtonList="toolButtonList"
                @onMetaDataChange="handleMetaDataChange" @onToolClick="handleToolClick"
                @onRowClick="handleRowClick">
  </PageTemplate>
</template>
<script>
import PageTemplate from '@/components/page-template';
import { transmitColFromGrid, transmitMail, getParams } from '@/utils';
import mixin from './mixin';

const urlParamObj = getParams(window.location.search);
export default {
  name: 'PageOthersCompeteDownList',
  mixins: [mixin],
  components: { PageTemplate },
  data() {
    return {
      tableRequest: {
        url: '/ajax.do?method=ajaxAction&managerName=affairManager',
        managerMethod: 'findOtherGrabData',
        otherArgs: { app: 1, newList: true, templeteIds: urlParamObj.textfield || ''}
      },
      metaDataRequestParams: {
        "key": "LIST_DONE_GRAB",
        "platform": 0,
      },
      toolButtonList: [],
    };
  },
  methods: {
    handleMetaDataChange({ globalParam }) {
      const needButtonList = [['transmit', ['transmitCol', 'transmitMail']]];
      this.initToolButtonList(needButtonList, globalParam);
    },
    handleToolClick(buttonId, { selectedRows, metaData }, resetTableData) {
      switch (buttonId) {
        case 'transmitCol':
          transmitColFromGrid(selectedRows, resetTableData, null, metaData.globalParam.isSecretLevelEnable);
          break;
        case 'transmitMail':
          transmitMail(selectedRows, resetTableData);
          break;
      }
    },
  }
};
</script>
